package com.game.message.jpb.codec;

import com.game.message.Msg;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

public class JPbEncoder extends MessageToByteEncoder<Msg> {

	@Override
	protected void encode(ChannelHandlerContext ctx, Msg msg, ByteBuf out) throws Exception {
		out.writeInt(msg.getLength());
		out.writeInt(msg.getMsgId());
		out.writeBytes(msg.getBody());
	}

}
